<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta http-equiv=Content-Type content="text/html;charset=utf-8">
    <div th:insert="main :: common_head"></div>
    <link rel="stylesheet" type="text/css" th:href="@{/css/searchableSelect.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/searchableSelect1.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/searchableSelect2.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/searchableSelect3.css}"/>
</head>
<style>
    .noBorder {
        border: none;
    }

    .mylabel {
        display: inline;
    }

    .greenColor {
        color: green;
    }

    .redColor {
        color: red;
    }
</style>

<body>
    <!--删除提示模态框1-->
    <div class="modal fade" id="delcfmModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
        aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" id="myModalLabel">提示</h4>
                </div>
                <div class="modal-body">是否要删除？</div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" onclick="deleteProperty()">确定</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div>
    <!--删除提示模态框结束-->

    <!--删除提示模态框2-->
    <div class="modal fade" id="delcfmModel1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1"
        aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" id="myModalLabel1">提示</h4>
                </div>
                <div class="modal-body">是否要删除？</div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" onclick="deletePropertyById()">确定</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div>
    <!--删除提示模态框结束-->

    <!--删除提示模态框3-->
    <div class="modal fade" id="delcfmModel2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2"
        aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" id="myModalLabel2">提示</h4>
                </div>
                <div class="modal-body">是否要删除？</div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" onclick="deleteRelation1()">确定</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div>
    <!--删除提示模态框结束-->

    <div class="container-fluid-full">
        <div class="row-fluid">

            <noscript>
                <div class="alert alert-block span10">
                    <h4 class="alert-heading">Warning!</h4>
                    <p>You need to have <a href="" target="_blank">JavaScript</a> enabled to use this site.</p>
                </div>
            </noscript>

            <!-- start: Content -->
            <div id="content" class="span10" style="width: 100%;">
                <ul class="breadcrumb" th:if="${#request.getParameter('breadcrumb') == 'true'}">
                    <li>
                        <i class="fas fa-circle-notch"></i>
                        <a id="home" href="#" onclick="parent.location.reload()">主页</a>
                        <i class="icon-angle-right"></i>
                    </li>
                    <li><a href="#">[[${device.deviceName}]]信息修改</a></li>
                </ul>
                <div class="row-fluid sortable">
                    <div class="box span12">
                        <div class="box-header" data-original-title>
                            <h2><i class="halflings-icon white edit"></i><span
                                    class="break"></span>[[${deviceName}]]属性管理</h2>
                        </div>
                        <div class="box-content">
                            <form class="form-horizontal" id="form2" enctype="multipart/form-data" method="post">
                                <input type="hidden" id="typeId" th:value="${device.deviceType.typeId}">
                                <fieldset>
                                    <div class="control-group">
                                        <label class="control-label">设备ID</label>
                                        <div class="controls">
                                            <span class="input-xlarge uneditable-input" id="deviceId"
                                                th:value="${device.deviceId}" th:text="${device.deviceId}"></span>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">设备名</label>
                                        <div class="controls">
                                            <input class="input-xlarge focused" type="text" placeholder=""
                                                th:value="${device.deviceName}" onchange="checkName()" id="deviceName"
                                                name="deviceName">
                                            <div style="display: inline" id="checkName">
                                            </div>
                                            <span style="color:red;font-size: 20px">*</span>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">能量编码</label>
                                        <div class="controls">
                                            <select id="devPointId"  name="devPointId">
                                                <option th:value="${device.devPointId}"
                                                        th:text="${device.devName}" selected></option>
                                            </select>
                                            <span style="color:red;font-size: 20px">*</span>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">电量编码</label>
                                        <div class="controls">
                                            <select id="batteryPointId"  name="batteryPointId">
                                                <option th:value="${device.batteryPointId}"
                                                        th:text="${device.batteryName}" selected></option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">内温编码</label>
                                        <div class="controls">
                                            <select id="temperaturePointId"  name="temperaturePointId">
                                                <option th:value="${device.temperaturePointId}"
                                                        th:text="${device.temperatureName}" selected></option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="control-group" th:if="${device.deviceType.typeId==2}">
                                        <label class="control-label">放能完成标志</label>
                                        <div class="controls">
                                            <select id="endFlagId"  name="endFlagId">
                                                <option th:value="${device.endFlagId}"
                                                        th:text="${device.endFlagName}" selected></option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">是否纳入决策</label>
                                        <div class="controls">
                                            <select name="isPredicted" id="isPredicted">
                                                <option th:selected="${device.isPredicted eq 0}" value="0">纳入决策</option>
                                                <option th:selected="${device.isPredicted eq 1}" value="1">不纳入决策
                                                </option>
                                                <option th:selected="${device.isPredicted eq 2}" value="2">只显示策略建议
                                                </option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">影响因素选择</label>
                                        <div class="controls">
                                            <select name="enableFactors" id="enableFactors">
                                                <option value="0">光</option>
                                                <option value="1">风</option>
                                                <option value="2" selected="selected">所有</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="control-group" th:if="${device.deviceType.typeId==2}">
                                        <label class="control-label">上限温度</label>
                                        <div class="controls">
                                            <input class="input-xlarge focused" type="text" placeholder=""
                                                th:value="${device.upperTemp}" id="upperTemp" name="upperTemp"
                                                style="width: 100px">­°C
                                        </div>
                                    </div>
                                    <div class="control-group" th:if="${device.deviceType.typeId==2}">
                                        <label class="control-label">下限温度</label>
                                        <div class="controls">
                                            <input class="input-xlarge focused" type="text" placeholder=""
                                                th:value="${device.lowerTemp}" id="lowerTemp" name="lowerTemp"
                                                style="width: 100px">­°C
                                        </div>
                                    </div>
                                    <div class="control-group" th:if="${device.deviceType.typeId==2}">
                                        <label class="control-label">设备冷热属性</label>
                                        <div class="controls">
                                            <input class="input-xlarge focused" type="text" placeholder=""
                                                th:value="${device.coldorheat}" id="coldorheat" name="coldorheat">
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">平均每小时产能量</label>
                                        <div class="controls">
                                            <input class="input-xlarge focused" type="number" placeholder=""
                                                th:value="${device.power}" id="power" name="power">
                                            <span style="font-size: 20px">kWh</span>
                                            <span style="color:red;font-size: 20px">*</span>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">能效比</label>
                                        <div class="controls">
                                            <input class="input-xlarge focused" type="number" placeholder=""
                                                th:value="${device.conversionRate}" id="conversionRate"
                                                name="conversionRate">
                                            <span style="color:red;font-size: 20px">*</span>
                                        </div>
                                    </div>
                                    <!-- <div class="control-group" th:if="${#arrays.isEmpty(relationship)&&device.deviceType.typeId!=3}">-->
                                    <!--<label class="control-label">关联设备</label>-->
                                    <!--<div class="controls">-->
                                    <!--<select id="relDevice" class="select" name="relationDevice">-->
                                    <!--<option value="" name="relationDevice"></option>-->
                                    <!--</select>-->
                                    <!--&lt;!&ndash;<label class="mylabel">能耗比:</label>&ndash;&gt;-->
                                    <!--&lt;!&ndash;<input class="input-small focused" type="text" placeholder=""&ndash;&gt;-->
                                    <!--&lt;!&ndash;name="conversionRate">&ndash;&gt;-->
                                    <!--<label class="mylabel" >损耗率:</label>-->
                                    <!--<input class="input-small focused" type="text" placeholder=""-->
                                    <!--name="lossRate">-->
                                    <!--<input type="button" onclick="addRelation()" id="addRel" value="+">-->
                                    <!--&lt;!&ndash;<button type="button" onclick="addRelation()">+</button>&ndash;&gt;-->
                                    <!--</div>-->
                                    <!--</div>-->
                                    <!--<div class="control-group"  th:each="relation,relationStat:${relationship}">-->
                                    <!--<input type="hidden" th:id="'relId'+${relationStat.index}" name="relId" class="myRelId" th:value="${relation.id}">-->
                                    <!--<label class="control-label">关联设备</label>-->
                                    <!--<div class="controls">-->
                                    <!--<select th:id="'select'+${relationStat.index}" class="select"  name="relationDevice">-->
                                    <!--<option value=""  name="relationDevice"></option>-->
                                    <!--</select>-->
                                    <!--&lt;!&ndash;<label class="mylabel">能效比:</label>&ndash;&gt;-->
                                    <!--&lt;!&ndash;<input class="input-small focused" th:value="${relation.conversionRate}" type="number" placeholder=""&ndash;&gt;-->
                                    <!--&lt;!&ndash;name="conversionRate">&ndash;&gt;-->
                                    <!--<label class="mylabel" >损耗率:</label>-->
                                    <!--<input class="input-small focused" type="number" placeholder=""-->
                                    <!--name="lossRate" th:value="${relation.lossRate}">-->
                                    <!--<label class="mylabel" >能源属性:</label>-->
                                    <!--<select th:id="'propertySelect'+${relationStat.index}" class="select1"  name="energyTypeId">-->
                                    <!--<option value=""  name="energyTypeId"></option>-->
                                    <!--</select>-->
                                    <!--&lt;!&ndash;<button th:if="${relationStat.index>=1}" class="btn btn-danger myBtn" type="button" data-target="#delcfmModel2" >删除</button>&ndash;&gt;-->
                                    <!--<button th:if="${relationStat.index>=1}"  th:id="'relId'+${relation.id}" type="button" class="btn btn-danger" onclick="deleteRelation()" >删除</button>-->
                                    <!--&lt;!&ndash;<button id="btn0" th:if="${relationStat.index>=1}" class="btn btn-primary myBtn" type="button" data-target="#delcfmModel">删除</button>&ndash;&gt;-->
                                    <!--<input th:if="${relationStat.index==0}" type="button" onclick="addRelation()" id="addRel" value="+">-->
                                    <!--&lt;!&ndash;<button type="button" onclick="addRelation()">+</button>&ndash;&gt;-->
                                    <!--</div>-->
                                    <!--</div>-->
                                    <div class="control-group">
                                        <label class="control-label">能量上限</label>
                                        <div class="controls">
                                            <input class="input-xlarge focused" type="number" placeholder=""
                                                th:value="${device.cap}" name="cap" id="cap">
                                            <span style="font-size: 20px">kWh</span>
                                            <span style="color:red;font-size: 20px">*</span>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">设备状态选择</label>
                                        <label style="margin-top: 6px;" class="radio">
                                            <input name="deviceMonitorSwitch"
                                                type="radio" value="0" th:checked="${device.deviceMonitorSwitch eq 0}">
                                                停用</label>
                                        <label style="margin-top: 6px;" class="radio">
                                            <input name="deviceMonitorSwitch"
                                            th:checked="${device.deviceMonitorSwitch eq 1}" type="radio" value="1">
                                            启用</label>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">设备条件停用</label><!-- 纵排列-->
                                        <div class="controls" style="display: flex;flex-direction: column;">
                                            <div id="col0" style="display:block; text-align:left;">
                                                <label style="margin-top: 6px;" class="radio">
                                                    <input id="endIndex1" name="endButton" type="radio" value="1"
                                                        th:checked="${device.endButton eq 1}" onclick="endOnChange()">
                                                    启用</label>
                                                <label style="margin-top: 6px;" class="radio">
                                                    <input id="endIndex2" name="endButton"
                                                        th:checked="${device.endButton eq 0}" type="radio" value="0"
                                                        onclick="endOffChange()">
                                                    关闭</label>
                                            </div>
                                            <div id="col1" style="display: block;text-align: left;">
                                                <!-- 横排列停用条件 -->
                                                <div class="controls"
                                                    style="display:flex; flex-direction:row; margin-left:0px; margin-top:10px;">
                                                    <div id="row1"
                                                        style="display: block;text-align: left;padding-left: 7px;">
                                                        <select name="endCondition" id="endCondition"
                                                            onchange="effectype(this.value)" style="width: 110px;">
                                                            <option th:selected="${device.endCondition eq 0}" value="0"
                                                                selected="selected">天气</option>
                                                            <option th:selected="${device.endCondition eq 1}" value="1">
                                                                风力</option>
                                                            <option th:selected="${device.endCondition eq 2}" value="2">
                                                                温度</option>
                                                            <option th:selected="${device.endCondition eq 3}" value="3">
                                                                湿度</option>
                                                        </select>
                                                    </div>
                                                    <div id="row2"
                                                        style="display: block;text-align: left;padding-left: 7px;">
                                                        <select name="endOperator" id="endOperator"
                                                            onchange="effectype(this.value)" style="width: 110px;">
                                                            <option th:selected="${device.endOperator eq 0}" value="0"
                                                                selected="selected"> > </option>
                                                            <option th:selected="${device.endOperator eq 1}" value="1">
                                                                < </option>
                                                            <option th:selected="${device.endOperator eq 2}" value="2">
                                                                = </option>
                                                            <option th:selected="${device.endOperator eq 3}" value="3">
                                                                >= </option>
                                                            <option th:selected="${device.endOperator eq 4}" value="4">
                                                                <= </option>
                                                        </select>
                                                    </div>
                                                    <div id="row3"
                                                        style="display: block;text-align: left;padding-left: 7px;">
                                                        <input class="input-xlarge focused" type="text" placeholder=""
                                                            th:value="${device.endValue}" id="endValue" name="endValue">
                                                        <span style="color:red;font-size: 20px">*</span>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">启用影响因素</label>
                                        <div class="controls" style="display: flex;flex-direction: row;">
                                            <div id="row0" style="display: block;text-align: left;">
                                                <select name="startButton" id="startButton"
                                                    onchange="startSelect(this.value)">
                                                    <option th:selected="${device.startButton eq 0}" value="0"
                                                        selected="selected">模型计算</option>
                                                    <option th:selected="${device.startButton eq 1}" value="1">按条件开启
                                                    </option>
                                                    <option th:selected="${device.startButton eq 2}" value="2">根据开启时间开启
                                                    </option>
                                                </select>
                                            </div>
                                            <div id="row4" style="display: block;text-align: left;padding-left: 7px;">
                                                <select name="startCondition" id="startCondition"
                                                    onchange="effectype(this.value)" style="width: 110px;">
                                                    <option th:selected="${device.startCondition eq 0}" value="0"
                                                        selected="selected">天气</option>
                                                    <option th:selected="${device.startCondition eq 1}" value="1">风力
                                                    </option>
                                                    <option th:selected="${device.startCondition eq 2}" value="2">温度
                                                    </option>
                                                    <option th:selected="${device.startCondition eq 3}" value="3">湿度
                                                    </option>
                                                </select>
                                            </div>
                                            <div id="row5" style="display: block;text-align: left;padding-left: 7px;">
                                                <select name="startOperator" id="startOperator"
                                                    onchange="effectype(this.value)" style="width: 110px;">
                                                    <option th:selected="${device.startOperator eq 0}" value="0"
                                                        selected="selected"> > </option>
                                                    <option th:selected="${device.startOperator eq 1}" value="1">
                                                        < </option>
                                                    <option th:selected="${device.startOperator eq 2}" value="2"> =
                                                    </option>
                                                    <option th:selected="${device.startOperator eq 3}" value="3"> >=
                                                    </option>
                                                    <option th:selected="${device.startOperator eq 4}" value="4">
                                                        <= </option>
                                                </select>
                                            </div>
                                            <div id="row6" style="display: block;text-align: left;padding-left: 7px;">
                                                <input class="input-xlarge focused" type="text" placeholder=""
                                                    th:value="${device.startValue}" id="startValue" name="startValue">
                                                <span style="color:red;font-size: 20px">*</span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">设备开启时间</label>
                                        <div class="controls">
                                            <!--<input class="input-xlarge focused" type="text" placeholder=""-->
                                            <!--name="cap" id="cap">-->
                                            <select name="time" id="timeStart">
                                                <option th:selected="${startTime eq '0'}" value="0">0:00</option>
                                                <option th:selected="${startTime eq '1'}" value="1">1:00</option>
                                                <option th:selected="${startTime eq '2'}" value="2">2:00</option>
                                                <option th:selected="${startTime eq '3'}" value="3">3:00</option>
                                                <option th:selected="${startTime eq '4'}" value="4">4:00</option>
                                                <option th:selected="${startTime eq '5'}" value="5">5:00</option>
                                                <option th:selected="${startTime eq '6'}" value="6">6:00</option>
                                                <option th:selected="${startTime eq '7'}" value="7">7:00</option>
                                                <option th:selected="${startTime eq '8'}" value="8">8:00</option>
                                                <option th:selected="${startTime eq '9'}" value="9">9:00</option>
                                                <option th:selected="${startTime eq '10'}" value="10">10:00</option>
                                                <option th:selected="${startTime eq '11'}" value="11">11:00</option>
                                                <option th:selected="${startTime eq '12'}" value="12">12:00</option>
                                                <option th:selected="${startTime eq '13'}" value="13">13:00</option>
                                                <option th:selected="${startTime eq '14'}" value="14">14:00</option>
                                                <option th:selected="${startTime eq '15'}" value="15">15:00</option>
                                                <option th:selected="${startTime eq '16'}" value="16">16:00</option>
                                                <option th:selected="${startTime eq '17'}" value="17">17:00</option>
                                                <option th:selected="${startTime eq '18'}" value="18">18:00</option>
                                                <option th:selected="${startTime eq '19'}" value="19">19:00</option>
                                                <option th:selected="${startTime eq '20'}" value="20">20:00</option>
                                                <option th:selected="${startTime eq '21'}" value="21">21:00</option>
                                                <option th:selected="${startTime eq '22'}" value="22">22:00</option>
                                                <option th:selected="${startTime eq '23'}" value="23">23:00</option>
                                            </select>
                                            <span>至</span>
                                            <select name="time" id="timeEnd">
                                                <option th:selected="${endTime eq '0'}" value="0">0:00</option>
                                                <option th:selected="${endTime eq '1'}" value="1">1:00</option>
                                                <option th:selected="${endTime eq '2'}" value="2">2:00</option>
                                                <option th:selected="${endTime eq '3'}" value="3">3:00</option>
                                                <option th:selected="${endTime eq '4'}" value="4">4:00</option>
                                                <option th:selected="${endTime eq '5'}" value="5">5:00</option>
                                                <option th:selected="${endTime eq '6'}" value="6">6:00</option>
                                                <option th:selected="${endTime eq '7'}" value="7">7:00</option>
                                                <option th:selected="${endTime eq '8'}" value="8">8:00</option>
                                                <option th:selected="${endTime eq '9'}" value="9">9:00</option>
                                                <option th:selected="${endTime eq '10'}" value="10">10:00</option>
                                                <option th:selected="${endTime eq '11'}" value="11">11:00</option>
                                                <option th:selected="${endTime eq '12'}" value="12">12:00</option>
                                                <option th:selected="${endTime eq '13'}" value="13">13:00</option>
                                                <option th:selected="${endTime eq '14'}" value="14">14:00</option>
                                                <option th:selected="${endTime eq '15'}" value="15">15:00</option>
                                                <option th:selected="${endTime eq '16'}" value="16">16:00</option>
                                                <option th:selected="${endTime eq '17'}" value="17">17:00</option>
                                                <option th:selected="${endTime eq '18'}" value="18">18:00</option>
                                                <option th:selected="${endTime eq '19'}" value="19">19:00</option>
                                                <option th:selected="${endTime eq '20'}" value="20">20:00</option>
                                                <option th:selected="${endTime eq '21'}" value="21">21:00</option>
                                                <option th:selected="${endTime eq '22'}" value="22">22:00</option>
                                                <option th:selected="${endTime eq '23'}" value="23">23:00</option>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="control-group">
                                        <label class="control-label">设备启动间隔</label>
                                        <div class="controls">
                                            <input class="input-xlarge focused" type="number" placeholder=""
                                                th:value="${device.intervalTime}" name="intervalTime" id="intervalTime">
                                            <span style="font-size: 20px">min</span>
                                            <span style="color:red;font-size: 20px">*</span>
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">最大功率自动调节</label>
                                        <div class="controls" style="display: flex; flex-direction: column;">
                                            <div>
                                                <label class="control-label">是否自动调节</label>
                                                <label style="margin-top: 6px;" class="radio">
                                                    <input name="powerMonitorSwitch"
                                                        type="radio" value="1" th:checked="${device.powerMonitorSwitch eq 1}" onclick="autoChangeYes()">
                                                        是</label>
                                                <label style="margin-top: 6px;" class="radio"><input name="powerMonitorSwitch"
                                                    th:checked="${device.powerMonitorSwitch eq 0}" type="radio" value="0"
                                                        onclick="autoChangeNo()">否</label>
                                                <!-- <span style="color:red;font-size: 20px;margin-top: 6px;">*</span> -->
                                            </div>
                                            <div  id="autoAdjustElem"  th:style="'display:' + @{(${device.powerMonitorSwitch eq 0} ? 'none' : 'inline-block')} + ''">
                                                <label class="control-label">自动调节持续天数</label>
                                                <input class="input-xlarge focused" type="number" placeholder=""
                                                    th:value="${device.autoAdjustLastTime}" name="autoAdjustLastTime"
                                                    id="autoAdjustLastTime" style="margin-left: 40px;">
                                            </div>
                                        </div>
                                    </div>

                                    <div class="control-group">
                                        <label class="control-label">设备图片</label>
                                        <div class="controls" style="position: relative">
                                            <!--<img th:src="'data:image/png;base64,'+${device.picPath}"/>-->
                                            <input class="input-xlarge focused" onchange="previewPic()" type="file"
                                                accept="image/jpg,image/jpeg,image/png,image/PNG" placeholder=""
                                                name="pic" id="pic">
                                        </div>
                                        <div
                                            style="width: 80px;height: 80px;background-color: #578ebe;margin-left: 180px">
                                            <img id="showImg" style="width: 80px;height: 80px;"
                                                th:src="${device.picPath}" />
                                        </div>
                                    </div>
                                    <div class="control-group">
                                        <label class="control-label">高亮图片</label>
                                        <div class="controls" style="position: relative">
                                            <input class="input-xlarge focused"
                                                accept="image/jpg,image/jpeg,image/png,image/PNG" type="file"
                                                placeholder="" name="pic" onchange="previewPic1()" id="highlightPic">
                                        </div>
                                        <div
                                            style="width: 80px;height: 80px;background-color: #578ebe;margin-left: 180px">
                                            <img id="showImg1" style="width: 80px;height: 80px;"
                                                th:src="${device.highlightPicPath}" />
                                        </div>
                                    </div>
                                    <div class="control-group" th:each="property:${device.propertyList}">
                                        <input type="hidden" th:value="${property.propertyId}" name="propertyId">
                                        <input class="control-label noBorder" placeholder="属性名" name="propertyName"
                                            th:value="${property.propertyDes}">
                                        <div class="controls">
                                            <input class="input-xlarge focused" type="text"
                                                th:value="${property.propertyValue}" name="propertyValue">
                                            <!--<a th:id="property+${property.propertyId}" class="btn btn-danger" href="javascript:void(0)" th:onclick="'javascript:deletePropertyById('+${property.propertyId}+');'">删除</a>-->
                                            <!--<a th:id="${property.propertyId}" href="javascript:void(0)" class="btn btn-danger" onclick="deleteProperty1()" >删除</a>-->
                                            <button th:id="${property.propertyId}" type="button" class="btn btn-danger"
                                                onclick="deleteProperty1()">删除</button>
                                        </div>
                                    </div>
                                    <div class="form-actions">
                                        <button type="submit" class="btn btn-primary"
                                            onclick="editDevice();return false">提交</button>
                                        <button type="button" onclick="toDevice()" class="btn btn-primary">返回</button>
                                        <!--<button type="button" class="btn btn-primary" id="addAttr" onclick="addProperty()">添加属性</button>-->
                                    </div>
                                </fieldset>
                            </form>
                        </div>
                    </div>
                    <!--/span-->
                </div>
                <!--/row-->
            </div>
        </div>
    </div>

    <div class="modal hide fade" id="myModal">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal">×</button>
            <h3>Settings</h3>
        </div>
        <div class="modal-body">
            <p>Here settings can be configured...</p>
        </div>
        <div class="modal-footer">
            <a href="#" class="btn" data-dismiss="modal">Close</a>
            <a href="#" class="btn btn-primary">Save changes</a>
        </div>
    </div>
    <div class="common-modal modal fade" id="common-Modal1" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-content">
            <ul class="list-inline item-details">
                <li><a href="http://sc.chinaz.com">Admin templates</a></li>
                <li><a href="http://sc.chinaz.com">Bootstrap themes</a></li>
            </ul>
        </div>
    </div>

    <div class="clearfix"></div>

    <div th:replace="main::common_js"></div>
    <script th:src="@{/js/searchableSelect.js}"></script>
    <script th:src="@{/js/searchableSelect1.js}"></script>
    <script th:src="@{/js/searchableSelect2.js}"></script>
    <script th:src="@{/js/searchableSelect3.js}"></script>
    <script th:src="@{/js/deviceGetAllPoint.js}"></script>
    <script th:src="@{/js/detect-element-resize.js}"></script>

    <script th:inline="javascript">
        breadcrumb()
        var startSelect1 = 1;
        var endSelect = 1;
        window.onload = function () {
            parent.modifyTitle([[${ device.deviceName }]])
            var end1 = document.getElementById("endIndex1").checked;
            var end2 = document.getElementById("endIndex2").checked;
            var options = $("#startButton option:selected");
            var val = options[0].value;
            if (val == "1") {
                //initAnalysisBar1("1");//发送一个ajax请求
                startSelect1 = 0;
                $("#row4").css("display", "block"); //显示
                $("#row5").css("display", "block");
                $("#row6").css("display", "block");
            } else if (val == "2") {
                //initAnalysisBar2("1");//发送一个ajax请求
                startSelect1 = 1;
                $("#row4").css("display", "none");
                $("#row5").css("display", "none");
                $("#row6").css("display", "none");
            } else if (val == "0") {
                startSelect1 = 0;
                //initAnalysisBar3("1");//发送一个ajax请求
                $("#row4").css("display", "none");
                $("#row5").css("display", "none");
                $("#row6").css("display", "none");
            }
            if (end2 == true) {
                endSelect = 0;
                $("#row1").css("display", "none");
                $("#row2").css("display", "none");
                $("#row3").css("display", "none");
            }

            addResizeListener(document.getElementsByTagName("body")[0], detectCallback);
        }

        var detectCallback = function () {
            setParentIframeHeight('content-iframe');
        };

        function setParentIframeHeight(id) {
            var parentIframe = parent.document.getElementById(id);
            sHeight = document.body.scrollHeight
            console.log(sHeight)
            parentIframe.style.height = sHeight + 'px'
        }
    </script>

    <script>
        //最大功率调节为是，自动调节天数设置默认值为3
        function autoChangeYes() {
            document.getElementById("autoAdjustElem").style.display = "block";
            document.getElementById("autoAdjustLastTime").value = 3;
        }
        //最大功率调节为否，自动调节天数设置默认值为null
        function autoChangeNo() {
            document.getElementById("autoAdjustElem").style.display = "none";
            document.getElementById("autoAdjustLastTime").value = "";
        }

        function startSelect(ele) {
            if (ele == "1") {
                //initAnalysisBar1("1");//发送一个ajax请求
                startSelect1 = 1;
                $("#row4").css("display", "block"); //显示
                $("#row5").css("display", "block");
                $("#row6").css("display", "block");
            } else if (ele == "2") {
                //initAnalysisBar2("1");//发送一个ajax请求
                startSelect1 = 0;
                $("#row4").css("display", "none");
                $("#row5").css("display", "none");
                $("#row6").css("display", "none");
            } else if (ele == "0") {
                startSelect1 = 0;
                //initAnalysisBar3("1");//发送一个ajax请求
                $("#row4").css("display", "none");
                $("#row5").css("display", "none");
                $("#row6").css("display", "none");
            }
        }

        function endOnChange(ele) {
            //initAnalysisBar1("1");//发送一个ajax请求
            endSelect = 1;
            $("#row1").css("display", "block"); //显示
            $("#row2").css("display", "block");
            $("#row3").css("display", "block");
        }
        function endOffChange(ele) {
            //initAnalysisBar1("1");//发送一个ajax请求
            endSelect = 0;
            $("#row1").css("display", "none");
            $("#row2").css("display", "none");
            $("#row3").css("display", "none");
        }

        var isCheckName = true;

        //返回上一页
        function toDevice() {
            window.history.back(-1);
        }

        //设备图片预览
        function previewPic() {
            //获取显示图片对象
            var preview = document.getElementById("showImg");   // 通过元素节点查找： document.querySelector('img');
            //获取选中图片对象（包含文件的名称、大小、类型等，如file.size）
            var file = document.getElementById("pic").files[0];
            //声明js的文件流
            var reader = new FileReader();
            if (file) {
                //通过文件流将文件转换成Base64字符串
                reader.readAsDataURL(file);
                //转换成功后
                reader.onloadend = function () {
                    //将转换结果赋值给img标签
                    preview.src = reader.result;
                    //输出结果
                    // document.getElementById("showText").value = reader.result;
                }
            } else {
                preview.src = "";
            }
        }

        //设备高亮图片预览
        function previewPic1() {
            //获取显示图片对象
            var preview = document.getElementById("showImg1");   // 通过元素节点查找： document.querySelector('img');
            //获取选中图片对象（包含文件的名称、大小、类型等，如file.size）
            var file = document.getElementById("highlightPic").files[0];
            console.log(file);
            //document.querySelector('input[type=file]').files[0];
            //声明js的文件流
            var reader = new FileReader();
            if (file) {
                //通过文件流将文件转换成Base64字符串
                reader.readAsDataURL(file);
                //转换成功后
                reader.onloadend = function () {
                    //将转换结果赋值给img标签
                    preview.src = reader.result;
                    //输出结果
                    // console.log(reader.result);
                    // console.log(typeof reader.result);
                    // document.getElementById("showText").value = reader.result;
                }
            } else {
                preview.src = "";
            }
        }

        //提交修改表单
        function editDevice() {
            var formData = new FormData($("#form2")[0]); //表单的formData数据
            var deviceId = document.getElementById("deviceId");//设备id
            var deviceIdValue = deviceId.innerHTML;
            var typeId = document.getElementById("typeId");//设备类型
            var typeIdValue = typeId.value;
            var start = document.getElementById("timeStart");//设备开启的起始时间
            var end = document.getElementById("timeEnd");//结束时间
            var startTime = Number(start.value);
            var endTime = Number(end.value);
            var startValue = document.getElementById("startButton");
            var endValue = document.getElementById("col0");
            var deviceName = document.getElementById("deviceName");//设备名称
            var conversionRate = document.getElementById("conversionRate");//能源比
            var power = document.getElementById("power");//平均每小时产能
            var cap = document.getElementById("cap");//上限
            //code改PointId
            var devCode = document.getElementById("devPointId");//设备编号
            var batteryCode = document.getElementById("batteryPointId");
            var temperatureCode = document.getElementById("temperaturePointId");

            if (temperatureCode.value == "") {
                window.parent.layerAlert('内温编码不能为空', {
                    icon: 5,
                    title: "提示"
                });
                return false;
            }
            if (batteryCode.value == "") {
                window.parent.layerAlert('电量编码不能为空', {
                    icon: 5,
                    title: "提示"
                });
                return false;
            }
            if (deviceName.value == "") {
                window.parent.layerAlert('设备名不能为空', {
                    icon: 5,
                    title: "提示"
                });
                return false;
            }
            if (devCode.value == "") {
                window.parent.layerAlert('能量编码不能为空', {
                    icon: 5,
                    title: "提示"
                });
                return false;
            }
            if (power.value == "") {
                window.parent.layerAlert('功率不能为空', {
                    icon: 5,
                    title: "提示"
                });
                return false;
            }
            if (conversionRate.value == "") {
                window.parent.layerAlert('能效比不能为空', {
                    icon: 5,
                    title: "提示"
                });
                return false;
            }
            if (startValue.value == "" && startSelect1 == 1) {
                window.parent.layerAlert('启用影响因素不能为空', {
                    icon: 5,
                    title: "提示"
                });
                return false;
            }
            if (endValue.value == "" && endSelect == 1) {
                window.parent.layerAlert('设备停用条件不能为空', {
                    icon: 5,
                    title: "提示"
                });
                return false;
            }
            if (cap.value == "") {
                window.parent.layerAlert('上限不能为空', {
                    icon: 5,
                    title: "提示"
                });
                return false;
            }
            console.log(formData + "--------------------------------")
            console.log(typeIdValue);
            formData.append("deviceId", deviceIdValue);
            //  var  mydata = document.getElementById("pic").files[0];
            //  var mydata1=document.getElementById("highlightPic").files[0];
            // var  formData = new FormData();
            // formData.append("pic", mydata);
            // formData.append("highlightPic",mydata1);
            //判断设备名是否可以使用
            if (isCheckName == false) {
                window.parent.layerAlert('请输入未被使用的设备名', {
                    icon: 5,
                    title: "提示"
                });
                return false;
            }
            // if ((startTime - endTime) >= 0) {
            //     window.parent.layerAlert('请输入合理的时间段', {
            //         icon: 5,
            //         title: "提示"
            //     });
            //     return false;
            // }
            $.ajax({
                type: "POST",
                data: formData,
                url: "/multipower/device/update",
                processData: false,
                contentType: false,
                success: function (res){
                    window.alert(res.message);
                    window.history.back(-1);
                    // window.location.href = "/multipower/device/" + res.data;
                },
            })
        }

        //设备名是否重复
        function checkName() {
            var deviceName = $("#deviceName").val();
            deviceName = $.trim(deviceName);
            console.log(deviceName);
            $.ajax({
                type: "GET",
                data: { deviceName: deviceName },
                url: "/multipower/device/check",
                success: function (data) {
                    console.log(data.check);
                    if (data.check == "yes") {
                        var span = document.createElement("span");
                        span.setAttribute("class", "greenColor");
                        span.innerHTML = "该设备名可以使用";
                        $("#checkName").html(span);
                        isCheckName = true;
                    }
                    if (data.check == "no") {
                        var span = document.createElement("span");
                        span.setAttribute("class", "redColor");
                        span.innerHTML = "该设备名已存在，请使用其他设备名";
                        $("#checkName").html(span);
                        isCheckName = false;
                    }
                },
            })
        }
    </script>

</body>

</html>